package logic

import (
	"2207a/bawei/user_srv/models/redis"
	"context"

	"2207a/bawei/user_srv/internal/svc"
	"2207a/bawei/user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type CacheSendSmsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCacheSendSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CacheSendSmsLogic {
	return &CacheSendSmsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CacheSendSmsLogic) CacheSendSms(in *user.CacheSendSmsRequest) (*user.CacheSendSmsResponse, error) {
	// todo: add your logic here and delete this line
	err := redis.CacheSendSms(in.Mobile, in.Code, in.Source)
	if err != nil {
		logx.Error("缓存短信错误", err)
		return nil, err
	}
	return &user.CacheSendSmsResponse{}, nil
}
